#include <iostream>

using namespace std;


//int main()
//{
//	int* p1 = new int;
//	int* p2 = new int[10];
//
//	delete p1;
//	delete[]p2;
//
//	int* p3 = new int(0);
//	int* p4 = new int[10] {0};
//	int* p5 = new int[10] {1, 2, 3, 4, 5, 6, 7, 8, 9};
//
//	cout << p5 << endl;
//
//	return 0;
//}

class A
{
public:
	A(int a1=1, int a2=2)
		:_a1(a1)
		,_a2(a2)
	{
		cout << "A(int a1, int a2)" << endl;
	}
	A(int& a)
	{
		_a1 = a;
		_a2 = a;
		cout << "A(int& a)" << endl;
	}


	~A()
	{
		cout << "~A()" << endl;
	}

private:
	int _a1;
	int _a2;
};

struct ListNode
{
	int val;
	ListNode* next;

	ListNode(int x)
		:val(x)
		,next(nullptr)
	{}
};

//int main()
//{
//	A* p1 = (A*)malloc(sizeof(A));
//	A* p2 = new A;
//	A* p3 = new A(1, 2);
//	A* p4 = new A[3];
//	A* p5 = new A[3]{A(1),A(2)};
//	A* p6 = new A[3]{ {1,2},{2,3} };
//
//	return 0;
//}

void fun()
{
	int n = 1;
	while (1)
	{
		void* p1 = new char[1024 * 1024*1024];
		cout << p1 << "->" << n << endl;
		n++;
	}
}

int main()
{
	/*try
	{
		void* p1 = new char[1024*1024*1024];
		void* p2 = new char[1024*1024*1024];
		void* p3 = new char[1024*1024*1024];
	}
	catch (const exception e)
	{
		cout << e.what() << endl;
	}*/

	try
	{
		fun();
	}
	catch (const exception&e)
	{
		cout << e.what() << endl;
	}

	return 0;
}